package com.hong.spring.controller;


import com.alibaba.fastjson.JSONObject;
import com.hong.spring.config.AppConfig;
import com.hong.spring.config.JavaConfigBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Auther: csh
 * @Date: 2020/8/18 17:36
 * @Description:
 */
@Controller
@RequestMapping("/")
@Slf4j
public class IndexController {

    @Autowired
    private AppConfig appConfig;


    @RequestMapping
    public String index() {

        log.info("首页");
        return "index";
    }

    @ResponseBody
    @GetMapping("apoloConfig")
    public JavaConfigBean apoloConfig() {
        log.info("获取配置信息{}", JSONObject.toJSONString(appConfig.javaConfigBean()));
        return appConfig.javaConfigBean();
    }

}
